package com.bwie.redkids.fragment;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.bwie.redkids.IndexActivity;
import com.bwie.redkids.R;
import com.bwie.redkids.adapter.ShoppingListBaseAdapter;
import com.bwie.redkids.bean.CartBean;
import com.bwie.redkids.utils.CartDBUtils;
import com.bwie.redkids.utils.FavoriteDBUtils;

public class ShoppingFragment extends Fragment implements OnClickListener {
	private CartDBUtils cartDBUtils = new CartDBUtils();
	private ArrayList<CartBean> arrayList;
	private ListView lv_goods_shoping;
	private ImageView imaAddress;
	private TextView tvAddress;
	private TextView tvMsg1;
	private TextView tvMsg2;
	private ImageView imageShow;
	private Button mButton;
	private ListView mLv;
	private TextView tvSum;
	private CheckBox check;
	private Button butSum;
	private TextView tvCheckAll;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.shopping_fragment, null, false);
		initView(view);
		return view;
	}

	private void initView(View view) {
		imaAddress = (ImageView) view.findViewById(R.id.ima_address);
		tvAddress = (TextView) view.findViewById(R.id.tv_address);
		tvMsg1 = (TextView) view.findViewById(R.id.textView1);
		tvMsg2 = (TextView) view.findViewById(R.id.textView2);
		imageShow = (ImageView) view.findViewById(R.id.imageView1);
		mButton = (Button) view.findViewById(R.id.but_shopping_car);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

		cartDBUtils.openSQLite(getActivity());
		arrayList = cartDBUtils.query();
		// lv_goods_shoping.setAdapter(new
		// ShoppingListBaseAdapter(getActivity(),
		// arrayList));
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		cartDBUtils.closeSQLite();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.but_shopping_car:
			Intent intent = new Intent(getActivity(), IndexActivity.class);
			startActivity(intent);
			break;

		default:
			break;
		}
	}
}
